<?php
/**
 *
 */
class DbTextField extends DbField {

    public function __construct($dbName,$null=true,$maxLength=null) {
        parent::__construct($dbName,$null);
        $this->maxLength=$maxLength;
    }

    public function toDb($value) {
        return "'".addslashes($value)."'";
    }

    public function isValid($value) {
        if (!parent::isValid($value))
            return false;
        // check length
        if ($this->maxLength and strlen($value)>$this->maxLength)
            return false;
        return true;
    }
}